version: Option<String>,
path: Option<String>,
git: Option<String>,
+ branch: Option<String>,
+ tag: Option<String>,
+ rev: Option<String>
}
#[deriving(Encodable,Decodable,PartialEq,Clone)]
(Some(string.clone()), SourceId::for_central())
},
DetailedDep(ref details) => {
+ let reference = details.branch.as_ref().map(|b| b.clone())
+ .or_else(|| details.tag.as_ref().map(|t| t.clone()))
+ .or_else(|| details.rev.as_ref().map(|t| t.clone()))
+ .unwrap_or_else(|| "master".to_str());
+
let new_source_id = details.git.as_ref().map(|git| {
// TODO: Don't unwrap here
- let kind = GitKind("master".to_str());
+ let kind = GitKind(reference.clone());
let url = url::from_str(git.as_slice()).unwrap();
let source_id = SourceId::new(kind, url);
// TODO: Don't do this for path
execs().with_stdout("hello world\n"));
})
+test!(cargo_compile_git_dep_branch {
+ let project = project("foo");
+ let git_project = git_repo("dep1", |project| {
+ project
+ .file("Cargo.toml", r#"
+ [project]
+
+ name = "dep1"
+ version = "0.5.0"
+ authors = ["carlhuda@example.com"]
+
+ [[lib]]
+
+ name = "dep1"
+ "#)
+ .file("src/dep1.rs", r#"
+ pub fn hello() -> &'static str {
+ "hello world"
+ }
+ "#)
+ }).assert();
+
+ git_project.process("git").args(["checkout", "-b", "branchy"]).exec_with_output().assert();
+ git_project.process("git").args(["branch", "-d", "master"]).exec_with_output().assert();
+
+ let project = project
+ .file("Cargo.toml", format!(r#"
+ [project]
+
+ name = "foo"
+ version = "0.5.0"
+ authors = ["wycats@example.com"]
+
+ [dependencies.dep1]
+
+ git = "file://{}"
+ branch = "branchy"
+
+ [[bin]]
+
+ name = "foo"
+ "#, git_project.root().display()))
+ .file("src/foo.rs", main_file(r#""{}", dep1::hello()"#, ["dep1"]));
+
+ let root = project.root();
+ let git_root = git_project.root();
+
+ assert_that(project.cargo_process("cargo-build"),
+ execs()
+ .with_stdout(format!("{} git repository `file:{}`\n\
+ {} dep1 v0.5.0 (file:{})\n\
+ {} foo v0.5.0 (file:{})\n",
+ UPDATING, git_root.display(),
+ COMPILING, git_root.display(),
+ COMPILING, root.display()))
+ .with_stderr(""));
+
+ assert_that(&project.root().join("target/foo"), existing_file());
+
+ assert_that(
+ cargo::util::process("foo").extra_path(project.root().join("target")),
+ execs().with_stdout("hello world\n"));
+})
+
+test!(cargo_compile_git_dep_tag {
+ let project = project("foo");
+ let git_project = git_repo("dep1", |project| {
+ project
+ .file("Cargo.toml", r#"
+ [project]
+
+ name = "dep1"
+ version = "0.5.0"
+ authors = ["carlhuda@example.com"]
+
+ [[lib]]
+
+ name = "dep1"
+ "#)
+ .file("src/dep1.rs", r#"
+ pub fn hello() -> &'static str {
+ "hello world"
+ }
+ "#)
+ }).assert();
+
+ git_project.process("git").args(["tag", "v0.1.0"]).exec_with_output().assert();
+ git_project.process("git").args(["checkout", "-b", "tmp"]).exec_with_output().assert();
+ git_project.process("git").args(["branch", "-d", "master"]).exec_with_output().assert();
+
+ let project = project
+ .file("Cargo.toml", format!(r#"
+ [project]
+
+ name = "foo"
+ version = "0.5.0"
+ authors = ["wycats@example.com"]
+
+ [dependencies.dep1]
+
+ git = "file://{}"
+ tag = "v0.1.0"
+
+ [[bin]]
+
+ name = "foo"
+ "#, git_project.root().display()))
+ .file("src/foo.rs", main_file(r#""{}", dep1::hello()"#, ["dep1"]));
+
+ let root = project.root();
+ let git_root = git_project.root();
+
+ assert_that(project.cargo_process("cargo-build"),
+ execs()
+ .with_stdout(format!("{} git repository `file:{}`\n\
+ {} dep1 v0.5.0 (file:{})\n\
+ {} foo v0.5.0 (file:{})\n",
+ UPDATING, git_root.display(),
+ COMPILING, git_root.display(),
+ COMPILING, root.display()))
+ .with_stderr(""));
+
+ assert_that(&project.root().join("target/foo"), existing_file());
+
+ assert_that(
+ cargo::util::process("foo").extra_path(project.root().join("target")),
+ execs().with_stdout("hello world\n"));
+})
test!(cargo_compile_with_nested_paths {
let git_project = git_repo("dep1", |project| {
project